/**
 * 
 */
package hu.gbalage.owl.editor.items.classes;

import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.layout.FormAttachment;
import org.eclipse.swt.layout.FormData;
import org.eclipse.swt.layout.FormLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.semanticweb.owl.model.OWLEntity;

import hu.gbalage.owl.editor.IOWLEditorItem;
import hu.gbalage.owl.editor.OWLEditorManager;
import hu.gbalage.owl.editor.TabManager;
import hu.gbalage.owl.editor.events.IOWLEntitySelectionListener;

/**
 * @author balage
 *
 */
public class ClassItem implements IOWLEditorItem {

	/* (non-Javadoc)
	 * @see hu.gbalage.owl.editor.IOWLEditorItem#getColor()
	 */
	public RGB getColor() {
		return new RGB(50,150,255);
	}

	/* (non-Javadoc)
	 * @see hu.gbalage.owl.editor.IOWLEditorItem#getTitle()
	 */
	public String getTitle() {
		return "Class";
	}

	Label label;
	
	/* (non-Javadoc)
	 * @see hu.gbalage.owl.editor.IOWLEditorItem#init(org.eclipse.swt.widgets.Composite, hu.gbalage.owl.editor.OWLEditorManager, hu.gbalage.owl.editor.TabManager)
	 */
	public void init(Composite parent, OWLEditorManager manager,
			TabManager tabManager) {
		
		parent.setLayout(new FormLayout());
		
		label = new Label(parent,SWT.NONE);
		
		tabManager.addEntitySelectionListener(new IOWLEntitySelectionListener(){
			public void entitySelected(OWLEntity entity) {
				if (entity.isOWLClass()){
					label.setText(entity.getURI().toString());
				}
			}
		});
		
		FormData data = new FormData();
		data.top = new FormAttachment(0);
		data.left = new FormAttachment(0);
		data.right = new FormAttachment(100);
		label.setLayoutData(data);
	}

}
